package com.prg.model.base;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;

/**
 * AuthUser entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "AUTH_USER", schema = "SSHE")
public class AuthUser implements java.io.Serializable {

	// Fields

	private String id;
	private String passwd;
	private String username;
	private String email;
	private String isStaff;
	private Set<AuthGroup> authGroups = new HashSet<AuthGroup>(0);

	// Constructors

	/** default constructor */
	public AuthUser() {
	}

	/** full constructor */
	public AuthUser(String passwd, String username, String email,
			String isStaff, Set<AuthGroup> authGroups) {
		this.passwd = passwd;
		this.username = username;
		this.email = email;
		this.isStaff = isStaff;
		this.authGroups = authGroups;
	}

	// Property accessors
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@Id
	@GeneratedValue(generator = "generator")
	@Column(name = "ID", unique = true, nullable = false, length = 100)
	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "PASSWD", length = 100)
	public String getPasswd() {
		return this.passwd;
	}

	public void setPasswd(String passwd) {
		this.passwd = passwd;
	}

	@Column(name = "USERNAME", length = 100)
	public String getUsername() {
		return this.username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Column(name = "EMAIL", length = 100)
	public String getEmail() {
		return this.email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Column(name = "IS_STAFF", length = 100)
	public String getIsStaff() {
		return this.isStaff;
	}

	public void setIsStaff(String isStaff) {
		this.isStaff = isStaff;
	}

	@ManyToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
	@JoinTable(name = "AUTH_USER_GROUP", schema = "SSHE", joinColumns = { @JoinColumn(name = "USER_ID", updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "GROUP_ID", updatable = false) })
	public Set<AuthGroup> getAuthGroups() {
		return this.authGroups;
	}

	public void setAuthGroups(Set<AuthGroup> authGroups) {
		this.authGroups = authGroups;
	}

}